/*******************************************
 * Copyright 2007 Aphrodite Framework for javaME .
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v2.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * Email : owner@aphroditeme.dev.java.net
 * Contributors:
 *     Kent Elton - initial API and implementation
 *******************************************/

package com.aphrodite.util.log;

public final class LogManager {

	public static final GlobalLogger getGlobalLogger(Appender appender) {
		try {
			Class clz = Class.forName("com.aphrodite.util.log.GlobalLoggerImpl");
			GlobalLogger log = (GlobalLogger) clz.newInstance();
			GlobalLoggerImpl.appender = appender;
			return log;
		} catch (InstantiationException e) {
			return null;
		} catch (IllegalAccessException e) {
			return null;
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
			return null;
		}
	}

	public static final Logger getLogger(Class logClass, Appender appender) {
		try {
			Class clz = Class.forName("com.aphrodite.util.log.LoggerImpl");
			Logger log = (Logger) clz.newInstance();
			((LoggerImpl) log).setClass(logClass);
			((LoggerImpl) log).setAppender(appender);
			return log;
		} catch (InstantiationException e) {
			return null;
		} catch (IllegalAccessException e) {
			return null;
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
			return null;
		}
	}
}
